home *** CD-ROM | disk | FTP | other *** search
- Path: ts13-06.upenn.edu!user
- From: sbb@eniac.seas.upenn.edu (Steve Bronstein)
- Newsgroups: comp.lang.c
- Subject: my program has a mind of its own (no really)
- Date: Tue, 09 Apr 1996 03:05:37 -0400
- Organization: University of Pennsylvania
- Message-ID: <sbb-0904960305370001@ts13-06.upenn.edu>
- NNTP-Posting-Host: ts13-06.upenn.edu
-
- I am writing a program (with cc as compiler) which has a number of arrays,
- which I have been verry careful to initialize with values, to avoid
- segmentation faults. The main part of the program is a loop beginning with
- an fgets statement to read in the next line from a file. Under certain
- circumstances, the program returns "Segmentation Fault" just as it reaches
- the beginning of this loop. When I put it a printf statement right before
- the loop to see how far it actually got, it worked.
-
- printf("something\n");
-
- When I removed "something", leaving just
-
- printf("\n");
-
- it gave me a segmentation fault again. I tried the same tactic at the
- beginning of the loop, and found that the program worked with a long word
- in the printf statement, but not a short word. Needless to say, I am
- slightly bewildered by this behavior, as the printf statement, at least to
- my knowledge, has no effect on my arrrays. If anyone has had a similar
- experience, or knows what's going on here, I'd be extremely grateful.
-
- Thanks,
-
- Steve Bronstein
- http://www.seas.upenn.edu/~sbb
-